<?php

namespace App\Backend\Controllers;

use App\Backend\Service\ContentModerationService;
use App\Backend\Controllers\BaseController;
use Illuminate\Http\Request;
use App\Helpers\AliyunHelper;

class ImageCheckController extends BaseController
{
    protected $moderationService;

    public function __construct(ContentModerationService $moderationService)
    {
        $this->moderationService = $moderationService;
    }


    /**
     * 处理图片检测请求
     */
    public function checkImage(Request $request)
    {

        $imagePath = $request->json('image_path');
        $imageUrl = $this->moderationService->getOssImageUrl($imagePath);
        //dd($imageUrl );
        $imageUrl ="http://xingfanapp.oss-cn-hangzhou.aliyuncs.com/uploads/modules/2025-07-31/fbcd1481-f1f3-43b5-a175-7b24d9c11e33.jpg";
        // 执行图片安全检测
        $result = $this->moderationService->checkImageAdvanced($imageUrl);
        $parsedResult = $this->moderationService->parseResult($result);

        $msg=[
            'image_url' => $imageUrl,
            'result' => $parsedResult
        ];
        $this->success($msg);
    }
}
